package stack_and_queue;

import java.util.LinkedList;

public class 图书整理2 {
    class CQueue {
        LinkedList<Integer> a,b;

        public CQueue() {
             a = new LinkedList<>();
             b = new LinkedList<>();
        }

        public void appendTail(int value) {
            a.addLast(value);
        }

        public int deleteHead() {
            if(!b.isEmpty()) return b.removeLast();
            if(a.isEmpty()) return -1;
            while (!a.isEmpty())
                b.addLast(a.removeLast());
            return b.removeLast();
        }
    }
}
